﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Zen4SyncPOCO.Enum.Admin;

namespace Zen4SyncClient
{
    /// <summary>
    /// Provides methods for comparing values extracted from a database
    /// </summary>
    internal static class SqlValueComparer
    {
        internal static bool ValuesAreEquals(SqlValueTypeEnum valuesType, object expected, object actual)
        {
            switch (valuesType)
            {
                case SqlValueTypeEnum.UniqueIdentifier:
                    return actual.ToString().ToUpper() == expected.ToString().ToUpper();
                case SqlValueTypeEnum.Int:
                    return (Int32)expected == (Int32)actual;
                case SqlValueTypeEnum.Varchar:
                    return actual.ToString() == expected.ToString();
                case SqlValueTypeEnum.Nvarchar:
                    return actual.ToString() == expected.ToString();
                case SqlValueTypeEnum.Bit:
                    return (Boolean)actual == (Boolean)expected;
                case SqlValueTypeEnum.DateTime:
                    return actual.ToString() == expected.ToString();
                case SqlValueTypeEnum.Xml:
                    return actual.ToString() == expected.ToString();
                case SqlValueTypeEnum.SmallInt:
                    return (Int16)expected == (Int16)actual;
                default:
                    return false;
            }
        }
    }
}
